﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DBQuestionList.aspx.cs" Inherits="ExaminationSys.View.SystemManage.DBQuestionList" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register src="DBQuestionEdit.ascx" TagName="DBQuestionEdit" TagPrefix="uc1" %>
<%@ Register src="DBQuestionSearchWindow.ascx" TagName="DBQuestionSearch" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>     
    <script type="text/javascript" language="javascript">
        var template = '<span style="color:{0};">{1}</span>';
        var LockRaw = function (value) {
            if (value == true)
                return Ext.String.format(template, "red", "是");
            else {
                return Ext.String.format(template, "green", "否");
            }
        };
        var beforeUpload = function () {
            var path = Ext.getCmp("UploadFile").getValue();
            if (path == undefined || path === '') {
                Ext.Msg.show({
                    title: '提示信息',
                    msg: '请先选择要上传的文件',
                    buttons: Ext.Msg.OK,
                    icon: Ext.MessageBox.WARNING
                }); return false;

            }
        };
        var afterUpload = function (path) {
            var hidden = document.getElementById("hiddenFilePath");
            hidden.value = path;
            return false;
        };
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X" />
        <ext:Store ID="Store_SheetName" runat="server">
              <Model>
                    <ext:Model ID="Model1" runat="server">
                         <Fields>
                            <ext:ModelField Name="SheetName" Type="String"/>
                            <ext:ModelField Name="SheetValue" Type="String" />
                        </Fields>
                    </ext:Model>
              </Model>
        </ext:Store>
        <ext:Store ID="StoreDBQuestion"
            runat="server" PageSize="20"
            ShowWarningOnFailure="true"
            AutoLoad="true"
            OnReadData="StoreDBQuestion_RefreshData">
            <Proxy>
                <ext:PageProxy>                    
                    <Listeners>
                        <Exception Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
                    </Listeners>
                </ext:PageProxy>
            </Proxy>
            <Model>
                <ext:Model ID="Model" runat="server" IDProperty="ID">
                    <Fields>
                        <ext:ModelField Name="ID"/>
                        <ext:ModelField Name="SerialNo" />
                        <ext:ModelField Name="Content" />
                        <ext:ModelField Name="SubjectType" />
                        <ext:ModelField Name="QuestionType" />
                        <ext:ModelField Name="Stage" />
                        <ext:ModelField Name="Challenge" />
                        <ext:ModelField Name="Knowledge" />
                        <ext:ModelField Name="KeyWord" />
                        <ext:ModelField Name="Point" />
                        <ext:ModelField Name="Lock" Type="Boolean" />
                        <ext:ModelField Name="AddTime" />
                    </Fields>
                </ext:Model>
            </Model>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="20" Mode="Raw" />
            </AutoLoadParams>            
            <Sorters>
                <ext:DataSorter Property="OpeatorTime" Direction="DESC" />
            </Sorters>
            <Listeners>
                <Exception Handler="Ext.MessageBox.alert('Load failed', response.statusText);"></Exception>
            </Listeners>
        </ext:Store>
        <ext:ViewPort ID="ViewPort1"  runat="server" Layout="BorderLayout">
            <Items>
                <ext:GridPanel 
                    ID="GridPanelDBQuestion" 
                    runat="server" Region="Center"
                    StoreID="StoreDBQuestion"
                    TrackMouseOver="true"
                    AutoExpandColumn="Title"
                    >
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:Button ID="BtnAdd" runat="server" Text="新增" Icon="UserAdd">
                                    <DirectEvents>
                                        <Click OnEvent="Add_Click"></Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="BtnBatchDelete" runat="server" Text="批量删除" Icon="UserDelete">
                                    <Listeners>
                                        <Click Handler="X.DoConfirm()" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Button ID="BtnBatchLock" runat="server" Text="批量锁定" Icon="LockKey">
                                    <DirectEvents>
                                        <Click OnEvent="BatchLock_Click"></Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="BtnBatchUnLock" runat="server" Text="解锁" Icon="LockEdit">
                                    <DirectEvents>
                                        <Click OnEvent="BatchUnLock_Click"></Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="BtnImportData" runat="server" Text="导入" Icon="PageExcel">
                                    <DirectEvents>
                                        <Click OnEvent="ImportData_Click"></Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:TextField ID="SearchText"  EmptyText="输入关键字" runat="server"></ext:TextField>
                                <ext:Button runat="server" ID="BtnGroupFind" Text="查找" Icon="Find" >                           
                                    <DirectEvents>
                                        <Click OnEvent="BtnFind_Click"></Click>
                                    </DirectEvents>                        
                                </ext:Button> 
                                <ext:Button runat="server" ID="BtnSearch" Text="高级查找" Icon="Find" >                           
                                    <DirectEvents>
                                        <Click OnEvent="BtnSearch_Click"></Click>
                                    </DirectEvents>                        
                                </ext:Button>                        
                                <ext:Button runat="server" ID="BtnRefresh" Text="刷新" Icon="ArrowRefresh" >                           
                                    <Listeners>
                                        <Click Handler="#{StoreDBQuestion}.reload();"  />
                                    </Listeners>                          
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <SelectionModel> 
                      <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1"  runat="server" Mode="Multi" CheckOnly="true" />
                    </SelectionModel>
                    <ColumnModel ID="ColumnModel1" runat="server">
			            <Columns>
                            <ext:Column ID="Column1" runat="server" Header="ID" DataIndex="ID" Width="150" Hidden="true" />
                            <ext:Column ID="Column3"  runat="server" Header="编号" DataIndex="SerialNo" Width="110" />
                            <ext:Column ID="Column5"  runat="server" Header="题目" DataIndex="Content" Width="230" />
                            <ext:Column ID="Column7"  runat="server" Header="题型" DataIndex="SubjectType"  Width="60" />
                            <ext:Column ID="Column9"  runat="server" Header="类型" DataIndex="QuestionType" Width="60" />
                            <ext:Column ID="Column11"  runat="server" Header="阶段" DataIndex="Stage" Width="50" />
                            <ext:Column ID="Column13"  runat="server" Header="难度" DataIndex="Challenge" Width="40" />
                            <ext:Column ID="Column15"  runat="server" Header="知识点" DataIndex="Knowledge" Width="160" />
                            <ext:Column ID="Column17"  runat="server" Header="关键字" DataIndex="KeyWord" Width="160" />
                            <ext:Column ID="Column19"  runat="server" Header="分值" DataIndex="Point" Width="60" />
                            <ext:Column ID="Column21" runat="server" Header="锁定" DataIndex="Lock" Width="50">
                                 <Renderer Fn="LockRaw" />
                            </ext:Column>
                            <ext:Column ID="Column23"  runat="server" Header="日期" DataIndex="AddTime"  Width="140" />
                            <ext:CommandColumn ID="CommandColumn1"  runat="server" Width="120">
                                <Commands >
                                    <ext:GridCommand Icon="NoteEdit" CommandName="Edit" Text="编辑" />   
                                    <ext:GridCommand Icon="Delete"  CommandName="Delete" Text="删除" />                         
                                </Commands>             
                                <DirectEvents>
                                    <Command OnEvent="Command">
                                        <ExtraParams>
                                             <ext:Parameter Name="Id" Value="record.getId()" Mode="Raw" />
                                             <ext:Parameter Name="command" Value="command" Mode="Raw" />
                                        </ExtraParams>
                                       <Confirmation BeforeConfirm="if (command=='Edit') return false;" ConfirmRequest="true" Message="是否删除该记录?" Title="提示" />
                                    </Command>
                                </DirectEvents>
                            </ext:CommandColumn>
			            </Columns>                
                    </ColumnModel>
                    <Listeners>
                    </Listeners> 
                    <View>
                        <ext:GridView ID="GridView1"  runat="server" />
                    </View>    
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" 
                            runat="server"                      
                            DisplayInfo="true" 
                            DisplayMsg="当前显示记录: {0} - {1}  共计: {2}" 
                            EmptyMsg="没有记录可以显示"                     
                            />
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:ViewPort>  
        <uc1:DBQuestionEdit ID="DBQuestionEditWindow" runat="server" />
        <uc1:DBQuestionSearch ID="DBQuestionSearchWindow" runat="server" />

        <ext:Window 
            ID="ImportDataWindow" 
            runat="server" 
            Icon="Group" 
            Title="导入数据"
            Width="600" 
            Height="200" 
            AutoShow="false" 
            Modal="true" 
            Hidden="true"
            Layout="Fit">
            <Items>       
                <ext:FormPanel 
                    ID="ImportDataPanel" 
                    runat="server" 
                    Icon="ChartOrganisation"
                    DefaultAnchor="95%"
                    Padding="5"
                    BodyPadding="10">
                    <Items>
                        <ext:FileUploadField FieldLabel="文件上传"  ID="UploadFile" runat="server" EmptyText="请选择文件" ButtonText="浏览..." Icon="Attach" AnchorHorizontal="95%" />
                        <ext:Button runat="server" ID="btnUpload" Text="上传" Icon="ArrowUp" Width="100" AnchorHorizontal="10%"  >
                            <Listeners>
                                <Click Fn="beforeUpload" />
                            </Listeners>
                            <DirectEvents>
                                <Click Timeout="60000" OnEvent="Upload_Click"
                                    Failure="Ext.Msg.show({
                                    title:   'Login Error',
                                    msg:     result.errorMessage,
                                    buttons: Ext.Msg.OK,
                                    icon:    Ext.MessageBox.ERROR});">
                                    <EventMask   ShowMask="true" Msg="正在处理..." MinDelay="1000" />                                              
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ComboBox ID="cbSheetName" runat="server" Editable="false" 
                            FieldLabel="Sheet名称" Width="250" EmptyText="请选择SheetName..." 
                                    StoreID="Store_SheetName" ValueField="SheetValue" DisplayField="SheetName"> 
                            <Listeners>
                            </Listeners>                          
                        </ext:ComboBox>  
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="BtnSaveImportData" runat="server" Text="保存" Icon="PageSave">
                    <Listeners>
                    </Listeners>
                    <DirectEvents>
                        <Click Timeout="600000" OnEvent="BtnSaveImportData_Click"
                            Failure="Ext.Msg.show({
                            title:   'Login Error',
                            msg:     result.errorMessage,
                            buttons: Ext.Msg.OK,
                            icon:    Ext.MessageBox.ERROR});">
                            <EventMask   ShowMask="true" Msg="正在处理..." MinDelay="1000" />                                               
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="取消" Icon="Cancel">
                    <Listeners>
                         <Click Handler="#{ImportDataWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
        <input type="hidden" id="hiddenFilePath" runat="server"/>
    </form>
</body>
</html>
